﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft Corp." file="DeleteServiceCertificateCommand.cs">
//   All rights reserved. See License.txt in the project root for license information.
// </copyright>
// 
// --------------------------------------------------------------------------------------------------------------------
namespace AzureManagement.AzureCommands
{
    using System;

    using RestClient;

    public class DeleteServiceCertificateCommand : AzureManagementCommand
    {
        private readonly string serviceName;

        private readonly string thumbprintAlg;

        private readonly string thumbprint;

        public DeleteServiceCertificateCommand(
            IAzureServiceContext serviceContext, string serviceName, string thumbprintAlg, string thumbprint)
            : base(serviceContext)
        {
            if (string.IsNullOrEmpty(serviceName))
            {
                throw new ArgumentException("Service name must not be null or empty.", "serviceName");
            }

            if (string.IsNullOrEmpty(thumbprintAlg))
            {
                throw new ArgumentException("Algorithm name must not be null or empty.", "thumbprintAlg");
            }

            if (string.IsNullOrEmpty(thumbprint))
            {
                throw new ArgumentException("Thumbprint name must not be null or empty.", "thumbprint");
            }

            this.serviceName = serviceName;
            this.thumbprintAlg = thumbprintAlg;
            this.thumbprint = thumbprint;
        }

        protected override RequestContext GetRequestContext()
        {
            return this.CreateDeleteOperationRequestContext();
        }

        protected override string FormatPath(IAzureServiceContext azureServiceContext)
        {
            return string.Format(
                        "{0}/services/hostedservices/{1}/certificates/{2}-{3}", 
                        azureServiceContext.SubscriptionId, 
                        this.serviceName, 
                        this.thumbprintAlg, 
                        this.thumbprint);
        }
    }
}